package com.xuetang9.t9.xinhuaxia.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xuetang9.t9.xinhuaxia.beans.Orderlist;
import com.xuetang9.t9.xinhuaxia.beans.UserOrderlist;
import com.xuetang9.t9.xinhuaxia.mappers.OrderlistMapper;
import com.xuetang9.t9.xinhuaxia.service.IOrderlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李亚奇
 * @version 1.0
 * @desc TODO
 * @date 2020/3/4 14:26
 * @copyright liyq
 * @address 成都西部国际金融中心2栋2201
 **/
@Service
public class OrderlistService implements IOrderlistService {
    @Autowired
    private OrderlistMapper orderlistMapper;
    @Override
    public boolean insert(Orderlist orderlist) {
        return orderlistMapper.insertSelective(orderlist)>0;
    }

    @Override
    public boolean remove(Long id) {
        return orderlistMapper.deleteByPrimaryKey(id)>0;
    }

    @Override
    public boolean update(Orderlist orderlist) {
        return orderlistMapper.updateByPrimaryKeySelective(orderlist)>0;
    }

    @Override
    public Orderlist queryById(Long id) {
        return orderlistMapper.queryById(id);
    }

    @Override
    public List<Orderlist> queryByOrderId(Long id) {
        return orderlistMapper.queryByOrderId(id);
    }

    @Override
    public Orderlist queryByProperty(Orderlist orderlist) {
        return orderlistMapper.selectOne(orderlist);
    }

    @Override
    public PageInfo<Orderlist> queryByPage(int currentPage, int perPageSize) {
        PageHelper.startPage(currentPage,perPageSize);
        PageHelper.orderBy("o_id desc");
        List<Orderlist> orderlists = orderlistMapper.queryAll();
        PageInfo<Orderlist> pageInfo = new PageInfo<>(orderlists);
        return pageInfo;
    }
}
